class Solution {
public:
    int evalRPN(vector<string>& tokens) {
        map<string,function<int(int,int)>> mp = {
            {"+",[](int a,int b){return a+b;}},
            {"-",[](int a,int b){return a-b;}},
            {"*",[](int a,int b){return a*b;}},
            {"/",[](int a,int b){return a/b;}}
        };
        stack<int> st;
        for(const auto& e: tokens)
        {
            if(mp.count(e))
            {
                int a = st.top();
                st.pop();
                int b = st.top();
                st.pop();
                st.push(mp[e](b,a));
            }
            else{
                st.push(stoi(e));
            }
        }
        return st.top();
    }
};